package com.infolab.aims.common.bean;

import java.io.Serializable;

import java.util.Date;

import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;


import org.codehaus.jackson.annotate.JsonIgnore;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import com.infolab.aims.GlobalConstant;

/**
 * @author subha
 *
 */
@MappedSuperclass
public abstract class AbstractModelBean implements Serializable {
	
	@JsonIgnore
	private String createdBy;
	
	@JsonIgnore
	@Transient
	private String createdByName;
	
	@JsonIgnore
	private String modifiedBy;
	
	@JsonIgnore
	@Transient
	private String modifiedByName;
	
	@JsonIgnore
	private Date dateCreated;
	
	@JsonIgnore
	private Date dateModified;
	
	@JsonIgnore
	public String getCreatedByName() {
		return createdByName;
	}
	public void setCreatedByName(String createdByName) {
		this.createdByName = createdByName;
	}
	@JsonIgnore
	public String getModifiedByName() {
		return modifiedByName;
	}
	public void setModifiedByName(String modifiedByName) {
		this.modifiedByName = modifiedByName;
	}
	@JsonIgnore
	public Date getDateCreated() {
		return dateCreated;
	}
	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}
	@JsonIgnore
	public Date getDateModified() {
		return dateModified;
	}
	public void setDateModified(Date dateModified) {
		this.dateModified = dateModified;
	}
	@JsonIgnore
	public String getCreatedBy() {
		return createdBy;
	}
	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}
	@JsonIgnore
	public String getModifiedBy() {
		return modifiedBy;
	}
	public void setModifiedBy(String modifiedBy) {
		this.modifiedBy = modifiedBy;
	}
	@JsonIgnore
	public String getLastModifiedBy()
	{
		if(modifiedBy!=null) return modifiedBy;
		if(createdBy!=null) return createdBy;
		return null;
	}
	@JsonIgnore
	public String getLastModifiedDate()
	{
		DateTimeFormatter fmt = DateTimeFormat.forPattern(GlobalConstant.DATE_TIME_FORMAT_JAVA);
		
		if(dateModified!=null) return new DateTime(dateModified.getTime()).toString(fmt);
		
		else if(dateCreated!=null) return new DateTime(dateCreated.getTime()).toString(fmt);
		
		return "";
	}
	@JsonIgnore
	public String getAuditContentHead()
	{
		return "N/A";
	}
	@JsonIgnore
	public String getAuditContentDetail()
	{
		return "N/A";
	}
	@JsonIgnore
	public String getAuditContentHeadForUserRole()
	{
		return "N/A";
	}
	@JsonIgnore
	public String getAuditCode()
	{
		return "N/A";
	}
	
	@JsonIgnore
	public String getAuditContentHeadForUpdateAssetPrices()
	{
		return "N/A";
	}
	
	@JsonIgnore
	public String getAuditContentDetailForUpdateAssetPrices()
	{
		return "N/A";
	}
	
	@JsonIgnore
	public String getAuditContentDetailForInitialBalance()
	{
		return "N/A";
	}
	@JsonIgnore
	public String getAuditContentHeadForInitialBalance()
	{
		return "N/A";
	}
	
	
	
	
	
	
	
	
}
